package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * url权限对应关系枚举
 *
 * @author kaka
 * @time 2018-8-5 15:18
 */
@Getter
public enum UrlPermissionEnum {
    /**
     * 模板中心
     */
    APP_MODULE_ADD("/pro/v1/appModule/open", "appModuleAdd", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.app_module_add", 1),

    /**
     * 新建应用权限
     */
    APPLICATION_ADD("/pro/v1/app/add", "applicationAdd", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.application_add", 2),

    APPLICATION_DELETE("/pro/v1/app/delete", "applicationDelete", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.application_delete", 2),

    APPLICATION_UPDATE("/pro/v1/app/update", "applicationUpdate", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.application_update", 2),

    APPLICATION_SORT("/pro/v1/app/sort", "applicationUpdate", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.application_sort", 2),

    APPLICATION_COPY("/pro/v1/app/copy", "applicationUpdate", UrlOperateEnum.COPY.getAlias(), "enum.urlPermission.memo.application_copy", 2),

    /**
     * 菜单相关权限
     */
    MENU_ADD_GROUP("/pro/v1/menu/addGroup", "menuSetUpdate", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.menu_add_group", 2),

    MENU_ADD_FORM("/pro/v1/menu/addForm", "menuSetUpdate", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.menu_add_form", 2),

    MENU_CHANGE_STATE("/pro/v1/menu/changeState", "menuSetUpdate", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.menu_change_state", 2),

    MENU_UPDATE("/pro/v1/menu/update", "menuSetUpdate", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.menu_update", 2),

    MENU_SORT("/pro/v1/menu/sort", "menuSetUpdate", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.menu_sort", 2),

    MENU_DELETE_GROUP("/pro/v1/menu/deleteGroup", "menuSetUpdate", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.menu_delete_group", 2),

    MENU_DELETE_FORM("/pro/v1/menu/deleteForm", "menuSetUpdate", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.menu_delete_form", 2),

    MENU_COPY("/pro/v1/menu/copy", "menuSetUpdate", UrlOperateEnum.COPY.getAlias(), "enum.urlPermission.memo.menu_copy", 2),
    /**
     * saas客户查重
     */

    COMMON_CUSTOMER_CHECK_REPEAT("/pro/v1/common/customerCheckRepeat", "customerDuplicate", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.common_customer_check_repeat", 2),

    COMMON_CLUE_CHECK_REPEAT("/pro/v1/common/clueCheckRepeat", "clueDuplicate", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.common_clue_check_repeat", 2),

    /**
     * 公司配置
     */
    COMPANY_CONFIG_ENABLE("/pro/v1/companyConfig/enable", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.company_config_enable", 1),

    COMPANY_CONFIG_SET_FISCAL("/pro/v1/companyConfig/setFiscal", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.company_config_set_fiscal", 1),

    COMPANY_CONFIG_SET_WORKING_DAY_MONTH("/pro/v1/companyConfig/setWorkingDayMonth", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.company_config_set_working_day_month", 1),

    COMPANY_CONFIG_SET_WORKING_DAY_WEEK("/pro/v1/companyConfig/setWorkingDayWeek", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.company_config_set_working_day_week", 1),

    COMPANY_CONFIG_SET_PERFORMANCE_FINISH("/pro/v1/companyConfig/setPerformanceFinish", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.company_config_set_performance_finish", 1),

    COMPANY_CONFIG_ENABLE_REPORT_TARGET("/pro/v1/companyConfig/enableReportTarget", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.company_config_enable_report_target", 1),

    DICTIONARY_ADD("/dictionary/add", "otherSet", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.dictionary_add", 1),


    /**
     * saas表单数据操作权限
     */
    LIST_BATCH_THOROUGH_DELETE("/pro/v1/list/batch/thorough/delete", "customerDelete", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.list_batch_thorough_delete", 1),

    /**
     * 员工列表权限（组织架构）
     */
    USER_ROLE_BATCH_DEL("/pro/v1/user/roleBatchDel", "organization", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.user_role_batch_del", 2),

    USER_ROLE_BATCH_ADD("/pro/v1/user/roleBatchAdd", "organization", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.user_role_batch_add", 2),

    USER_ADD_ROLE("/pro/v1/user/addRole", "organization", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.user_add_role", 2),

    USER_DEL_ROLE("/pro/v1/user/delRole", "organization", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.user_del_role", 2),

    USER_ADD_ASSIST("/pro/v1/user/addAssist", "organization", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.user_add_assist", 2),

    USER_DEL_ASSIST("/pro/v1/user/delAssist", "organization", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.user_del_assist", 2),

    /**
     * 角色相关权限
     */
    ROLE_ADD("/pro/v1/role/add", "rolePermission", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.role_add", 2),

    ROLE_DELETE("/pro/v1/role/delete", "rolePermission", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.role_delete", 2),

    ROLE_COPY("/pro/v1/role/copy", "rolePermission", UrlOperateEnum.COPY.getAlias(), "enum.urlPermission.memo.role_copy", 2),

    ROLE_DETAIL("/pro/v1/role/detail", "rolePermission", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.role_detail", 2),

    /**
     * 角色详情当角色权限分配出去后能看但不能改
     */
    ROLE_APP_DETAIL("/pro/v1/role/appDetail", "rolePermission", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.role_app_detail", 2),

    ROLE_MODULE_DETAIL("/pro/v1/role/moduleDetail", "rolePermission", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.role_module_detail", 2),

    ROLE_EDIT_NAME("/pro/v1/role/editName", "rolePermission", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.role_edit_name", 2),

    ROLE_EDIT_DATA_PERMISSION("/pro/v1/role/editDataPermission", "rolePermission", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.role_edit_data_permission", 2),

    ROLE_SAVE("/pro/v1/role/save", "organization", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.role_save", 2),

    /**
     * 表单设计
     */

    FORM_TEMPLATE_UPDATE("/pro/v1/form/save", "formSetUpdate", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.form_template_update", 2),

    FORM_TEMPLATE_GET("/pro/v1/form/get", "formSetView", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.form_template_get", 2),

    FORM_TEMPLATE_DELETE("/pro/v1/form/delete", "formSetDelete", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.form_template_delete", 2),

    /**
     * 流程相关权限
     */
    PROCESS_TEMPLATE_OPEN("/pro/v1/process/open", "processSetOpen",  UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.process_template_open", 2),

    PROCESS_TEMPLATE_CLOSE("/pro/v1/process/enable", "processSetClose",  UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.process_template_close", 2),

    PROCESS_TEMPLATE_UPDATE("/pro/v1/process/save", "processSetUpdate",  UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.process_template_update", 2),

    PROCESS_TEMPLATE_GET("/pro/v1/process/get", "processSetView",  UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.process_template_get", 2),
    /**
     * 表单数据删除权限
     */
    FORM_DATA_DELETE("/pro/v1/form/data/delete", "formDataDelete", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.form_data_delete", 3),

    /**
     * 业绩目标
     */
    PERFORMANCE_SET_EDIT("/pro/v1/performanceSet/edit", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.performance_set_edit", 2),

    PERFORMANCE_SET_SAVE("/pro/v1/performanceSet/save", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.performance_set_save", 2),

    PERFORMANCE_SET_DELETE("/pro/v1/performanceSet/delete", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.performance_set_delete", 2),

    PERFORMANCE_SET_ENABLE("/pro/v1/performanceSet/enable", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.performance_set_enable", 2),

    /**
     * pk相关权限
     */
    PK_SET_ENABLE("/pro/v1/pk/set/enable", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.pk_set_enable", 2),

    PK_SET_SAVE("/pro/v1/pk/set/saveName", "otherSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.pk_set_save", 2),
    // TODO 产品分类
    /**
     * 公海池分组
     */
//    CUSTOMER_PUBLIC_GROUP_UPDATE("/pro/v1/publicGroup/set/item", "customerPublicSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.public_group_update", 2),
//
//    CUSTOMER_PUBLIC_GROUP_SAVE("/pro/v1/publicGroup/set/save", "customerPublicSet", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.public_group_save", 2),
//
//    CUSTOMER_PUBLIC_GROUP_DELETE("/pro/v1/publicGroup/set/delete", "customerPublicSet", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.public_group_delete", 2),
//
//    CLUE_PUBLIC_GROUP_UPDATE("/pro/v1/publicGroup/set/item", "cluePublicSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.public_group_update", 2),
//
//    CLUE_PUBLIC_GROUP_SAVE("/pro/v1/publicGroup/set/save", "cluePublicSet", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.public_group_save", 2),
//
//    CLUE_PUBLIC_GROUP_DELETE("/pro/v1/publicGroup/set/delete", "cluePublicSet", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.public_group_delete", 2),

    /**
     * 签到设置
     */
    SIGN_IN_SET_UPDATE("/pro/v1/signIn/set/getConfig", "signInSet", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.sign_in_set_update", 2),

    SIGN_IN_SET_SAVE_CONFIG("/pro/v1/signIn/set/saveConfig", "signInSet", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.sign_in_set_save_config", 2),
    /**
     * 短信充值
     */
    SMS_FEE_CHARGE("/pro/v1/sms/fee/charge", "smsRecharge", UrlOperateEnum.CREATE.getAlias(), "enum.urlPermission.memo.sms_fee_charge", 2),

    SMS_FEE_GET_INFO("/pro/v1/sms/fee/getInfo", "smsRecharge", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.sms_fee_get_info", 2),

    SMS_FEE_CHECK_PAY_STATUS("/pro/v1/sms/fee/checkPayStatus", "smsRecharge", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.sms_fee_check_pay_status", 2),

    /**
     * 短信设置
     */
    SMS_SET_UPDATE("/pro/v1/sms/set/templateSave", "smsSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.sms_set_update", 2),

    /**
     * 工单评价
     */
    WORK_ORDER_SAVE_EVALUATION("/pro/v1/workOrder/center/evaluate/save", "workOrderRate", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.work_order_save_evaluation", 2),
    /**
     * 工单服务人员
     */
    WORK_ORDER_PERSON_LIST("/pro/v1/workOrderPerson/listAjax", "workOrderPerson", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.work_order_person_list", 2),

    WORK_ORDER_PERSON_EDIT("/pro/v1/workOrderPerson/edit", "workOrderPerson", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.work_order_person_edit", 2),

    WORK_ORDER_PERSON_SAVE("/pro/v1/workOrderPerson/save", "workOrderPerson", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.work_order_person_save", 2),

    WORK_ORDER_PERSON_DELETE("/pro/v1/workOrderPerson/delete", "workOrderPerson", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.work_order_person_delete", 2),
    /**
     * 工单设置
     */
    WORK_ORDER_SET_LIST("/pro/v1/workorder/set/templateList", "workOrderSet", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.work_order_set_list", 2),

    WORK_ORDER_SET_SAVE_CATEGORY("/pro/v1/workorder/set/saveCategory", "workOrderSet", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.work_order_set_save_category", 2),

    WORK_ORDER_SET_DEL_CATEGORY("/pro/v1/workorder/set/delCategory", "workOrderSet", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.work_order_set_del_category", 2),

    WORK_ORDER_SET_SORT_CATEGORY("/pro/v1/workorder/set/sortCategory", "workOrderSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.work_order_set_sort_category", 2),

    WORK_ORDER_SET_TEMPLATE_DETAIL("/pro/v1/workorder/set/templateDetail", "workOrderSet", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.work_order_set_template_detail", 2),

    WORK_ORDER_SET_SAVE_TEMPLATE("/pro/v1/workorder/set/saveTemplate", "workOrderSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.work_order_set_save_template", 2),

    WORK_ORDER_SET_ENABLE_TEMPLATE("/pro/v1/workorder/set/enableTemplate", "workOrderSet", UrlOperateEnum.UPDATE.getAlias(), "enum.urlPermission.memo.work_order_set_enable_template", 2),

    WORK_ORDER_SET_DEL_TEMPLATE("/pro/v1/workorder/set/delTemplate", "workOrderSet", UrlOperateEnum.DELETE.getAlias(), "enum.urlPermission.memo.work_order_set_del_template", 2),

    WORK_ORDER_SET_GET_RULE("/pro/v1/workorder/set/getRuleList", "workOrderSet", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.work_order_set_get_rule", 2),
    /**
     * 工单详情
     */
    WORK_ORDER_DETAIL("/pro/v1/mobile/form/data/detail", "workOrderView", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.work_order_detail", 2),

    /**
     * 工作报告
     */
    WORK_REPORT_GET_CONFIG("/pro/v1/workReport/set/getConfig", "workReportSet", UrlOperateEnum.READ.getAlias(), "enum.urlPermission.memo.work_report_get_config", 2),

    WORK_REPORT_SAVE_CONFIG("/pro/v1/workReport/save/getConfig", "workReportSet", UrlOperateEnum.SAVE.getAlias(), "enum.urlPermission.memo.work_report_save_config", 2),
    ;
    /**
     * 需要做权限校验的访问链接
     */
    private String url;

    /**
     * 对应的权限
     * see tb_pro_permission中的alias
     */
    private String permission;

    /**
     * 对应表单/报表中的具体操作
     */
    private String operation;

    /**
     * 权限对应中文描述
     */
    private String memo;

    /**
     * 权限类型，1：管理员权限，2：普通权限(SAAS),3:普通权限(PAAS)
     */
    private int type;

    UrlPermissionEnum(String url, String permission, String operation, String memo, int type) {
        this.url = url;
        this.permission = permission;
        this.memo = memo;
        this.operation = operation;
        this.type = type;
    }

    /**
     * 根据url获取枚举
     */
    public static UrlPermissionEnum getByUrl(String url) {
        for (UrlPermissionEnum cache : values()) {
            if (url.equals(cache.getUrl())) {
                return cache;
            }
        }
        return null;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
